import React, { Component } from 'react';
/* 1 引入axios */
import axios from 'axios'
/* 4 导入组件 */
import Item from './components'
class Index extends Component {
    constructor(props) {
        super(props)
        this.state = {
            playlists: []
        }
    }
    render() {
        return (
            <div>
                {/* 5 向子组件传递相关值或方法 */}
                <Item playlists={this.state.playlists} ></Item>
            </div>
        );
    }

    componentDidMount() {
        /* 2 获取接口数据 */
        axios.get('http://122.112.161.135:3000/top/playlist?cat=华语').then(res => {
            this.setState({
                playlists: res.data.playlists
            })
        })
    }
}

export default Index;
